$(function () {
    obj.init();
});

var obj = new function () {
    return {
        dataGrid: null,
        dom: {
            search: null,
            start: null,
            end:null
        },
        bookId: null,
        schoolId: null,
        init: function () {
            this.bookId  = xhTool.getQuery('bookId');
            this.schoolId  = xhTool.getQuery('schoolId');
            this.dom.start = $('#list_search_startTime').datetimebox({width: 150});
            this.dom.end = $('#list_search_endTime').datetimebox({width: 150});
            this.dom.start.datetimebox('setValue', xhTool.getNowDate(-30));
            this.dom.end.datetimebox('setValue', xhTool.getNowDateTime());
            this.dataGrid = new xhDataGrid($('#list'), 'Res/getBookUseDetail', {bookId: this.bookId,schoolId: this.schoolId, startTime: this.dom.start.getElementValue(),endTime: this.dom.end.getElementValue()});
            this.dataGrid.parseToolbar().init();
            this.dom.search = $('#bt_list_search');
            xhExtra.clearLoadSuccess(this.dataGrid);
            this.listener();
        },
        listener: function () {
            var $this = this;
            //查询
            $this.dom.search.click(function () {
                $this.funObj().search();
            });
            xhTool.bindDocKeyDown($this.dom.search);
        },
        funObj: function () {
            var $this = this;
            return {
                search: function () {
                    $this.dataGrid.reload({
                        search: {
                            // vague: xhExtra.getValue($('#list_search_vague')),
                        },
                        bookId: $this.bookId,
                        startTime: $this.dom.start.getElementValue(),
                        endTime: $this.dom.end.getElementValue()
                    });
                }
            }
        }
    }
};

